package org.javahispano.javacup.tacticas_aceptadas.jpautom.org.javahispano.javacup.tacticas.pitufos;

public class Mov implements Cloneable {
	private double vx;
	private double vy;
	private double vz;

	public Mov() {}
	public Mov(Mov m) {
		set(m);
	}
	public void set(Mov m) {
		vx=m.vx; vy=m.vy; vz=m.vz;
	}

	@Override
	public Object clone() {
		return new Mov(this);
	}


	// cartesianas
	public double getVx() {return vx;}
	public double getVy() {return vy;}
	public double getVz() {return vz;}

	public void setVx(double vx) {this.vx=vx;}
	public void setVy(double vy) {this.vy=vy;}
	public void setVz(double vz) {this.vz=vz;}

	public void setVxyz(double vx, double vy, double vz) {
		this.vx=vx; this.vy=vy; this.vz=vz;
	}
	public double getVxy() {return Math.hypot(vx, vy);}

	public void setRPhTh(double r, double ph, double th) {
		this.vx=r*Math.cos(th)*Math.cos(ph);
		this.vy=r*Math.cos(th)*Math.sin(ph);
		this.vz=r*Math.sin(th);
	}

	public double getUx() {
		return vx/getR();
	}

	public double getUy() {
		return vy/getR();
	}
	
	public double getUz() {
		return vz/getR();
	}

	// cilindricas
	public double getR() {
		return Math.sqrt(vx*vx+vy*vy+vz*vz);
	}

	public double getPhi() {
		return Math.atan2(vy, vx);
	}

	public double getTheta() {
		// ojo: no es el Theta tipico de coordenadas cilindricas
		return Math.atan(vz/Math.sqrt(vx*vx+vy*vy));
	}

	@Override
	public String toString() {
		return "Mov["+vx+", "+vy+", "+vz+"]";
	}

}
